package com.cn.qgx428.lazydiary.ui.activity.subActivity

import android.graphics.Color
import android.os.Bundle
import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity
import com.cn.qgx428.lazydiary.R
import com.cn.qgx428.lazydiary.Utils.SPUtil
import com.cn.qgx428.lazydiary.local.LAMessege
import com.cn.qgx428.lazydiary.local.LAction
import com.cn.qgx428.lazydiary.local.LManager
import com.cn.qgx428.lazydiary.ui.activity.BaseActivity

import kotlinx.android.synthetic.main.activity_budget_setting_activitiy.*

class BudgetSettingActivitiy : BaseActivity() {
    override fun initUI() {
        hindActionBar()
        setStatuBarColor(Color.BLACK)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_budget_setting_activitiy)
        initView()
    }

    private fun initView() {
        budgetSetting_back.setOnClickListener({finish()})
        budgetSetting_input.setText(SPUtil.getBillBudget())
        budgetSetting_save.setOnClickListener({
            var budget = budgetSetting_input.text.toString()
            if (budget.equals(""))
                budget = "0"
            SPUtil.saveBillBudget(budget)
            var msg = LAMessege()
            msg.arg1 = budget
            LManager.newInstance().trigger(LAction.ACTION_CHANGE_BUDGET,
                    msg)
            finish()
        })
    }

}
